package com.mooc.yohoshop.imgload;

import android.widget.ImageView;

import com.blankj.utilcode.util.ConvertUtils;
import com.mooc.yohoshop.R;
import com.mooc.yohoshop.filed.ApiConst;

import jp.wasabeef.glide.transformations.CropCircleTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

public class ImageLoad {

    public static void loadMatch(String urlPath, ImageView img){
        GlideApp.with(img.getContext())
                .load(ApiConst.IMGURL+urlPath)
                .centerCrop()
                .placeholder(R.drawable.default_loading)
                .error(R.drawable.tt_default_message_error_image)
                .into(img);
    }

    public static void loadCircle(String urlPath, ImageView img){
        GlideApp.with(img.getContext())
                .load(ApiConst.IMGURL+urlPath)
                .centerCrop()
                .transform(new CropCircleTransformation())
                .placeholder(R.drawable.default_loading)
                .error(R.drawable.tt_default_message_error_image)
                .into(img);
    }

    public static void loadMatchUrlRound(String urlPath, ImageView img){
        GlideApp.with(img.getContext())
                .load(urlPath)
                .centerCrop()
                .transform(new RoundedCornersTransformation(ConvertUtils.dp2px(5),0))
                .placeholder(R.drawable.default_loading)
                .error(R.drawable.tt_default_message_error_image)
                .into(img);
    }
    public static void loadMatchUrl(String urlPath, ImageView img){
        GlideApp.with(img.getContext())
                .load(urlPath)
                .centerCrop()
                .placeholder(R.drawable.default_loading)
                .error(R.drawable.tt_default_message_error_image)
                .into(img);
    }
}
